package com.usian.mapper;

import com.usian.realname.Realname;
import com.usian.square.Square;
import com.usian.user.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

    //登录
    @Select("select * from user where account=#{account} and password=#{password}")
    User login(User user);

    @Select("select * from user where id=#{id}")
    User selectById(Integer id);

    //注册
    @Select("insert into user(account,password) values(#{account},#{password})")
    User logon(User user);


    @Update("update user set name=#{name},sex=#{sex},img=#{img},introduction=#{introduction} where id=#{id}")
    int userInfoEdit(User user);

    @Select("select * from square where userId = #{id}")
    List<Square> selectUserPost(@Param("id") Integer id);

    @Select("select count(*) from square where userId=#{id}")
    Integer selectUserMypost(Integer id);

    @Select("select * from realname where card=#{card}")
    List<Realname> realname(String card);

    @Insert("insert into realname(userId,realname,card) values (#{userId},#{realname},#{card})")
    void saverealname(Integer userId, String realname, String card);

    @Select("select id from realname where card = #{card}")
    Integer updaterealnameById(String card);

    @Update("update user set realnameId=#{realnameId} where id=#{userId}")
    void updateById(Integer userId, Integer realnameId);

    @Select("select * from realname where userId = #{id}")
    Realname selectRealname(Integer id);

    @Select("select lucky from user where id=#{id}")
    List<User> selectUserLucky(Integer id);

    @Select("select lucky from user where id=#{id}")
    Integer selectUserMyLucky(Integer id);

    @Select("select charisma from user where id=#{id}")
    Integer selectCharisma(Integer id);

    @Delete("delete from square where id=#{id}")
    int deletePost(Integer id);


    @Update("update user set charisma=#{charisma} where id=#{id}")
    Integer UserLucky(Integer id, Integer charisma);



}
